<?php

namespace app\index\model;

use app\admin\model\Service;
use think\Model;

/**
 *  User
 * @property int $id               自增id
 * @property string $openid        openid
 * @property string $nickname      昵称
 * @property string $headimgurl    头像
 * @property string $id_card       身份证
 * @property string $mobile        手机号
 * @property int $service_id       客服id
 * @property int $department_id    部门id
 * @property int $shop_id          门店id
 * @property Service $market        销售
 * @property Service $service       客服
 * @property Service $department    部门
 * @property Service $shop          门店
 * @property Service $market        销售
 * @property int $status           0=>待审核 1=>审核通过 2=>审核不通过
 */
class User extends Model
{
    /**
     * @var string
     */
    protected $table = 'ws_users';
    const STATUS_WAIT = 0;
    const STATUS_PASS = 1;
    const STATUS_NO_PASS = 2;

    const STATUS_MAP = [
        self::STATUS_WAIT => '待审核',
        self::STATUS_PASS => '审核通过',
        self::STATUS_NO_PASS => '禁用'
    ];

    const STATUS_BTN_MAP = [
        self::STATUS_WAIT => '<span class="layui-btn layui-btn-warm layui-btn-radius">待审核</span>',
        self::STATUS_PASS => '<span class="layui-btn layui-btn-radius">启用</span>',
        self::STATUS_NO_PASS => '<span class="layui-btn layui-btn-danger layui-btn-radius">禁用</span>'
    ];
    /**
     * @return mixed
     */
    public function shop()
    {
        return $this->hasOne(Service::class, 'id', 'shop_id');
    }
    /**
     * @return mixed
     */
    public function service()
    {
        return $this->hasOne(Service::class, 'id', 'service_id');
    }
    /**
     * @return mixed
     */
    public function department()
    {
        return $this->hasOne(Service::class, 'id', 'department_id');
    }
    /**
     * @return mixed
     */
    public function market()
    {
        return $this->hasOne(Service::class, 'id', 'market_id');
    }
}
